package cn.edu.scau.cmi.liweihang.client;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;


public class ConsistComponentClient extends Application{

	 @Override
	 public void start(Stage primaryStage) throws Exception {
	  try {
	   Parent root = FXMLLoader.load(getClass().getResource("/cn/edu/scau/cmi/liweihang/composite/consist/ConsistComposite.fxml"));
	   Scene scene = new Scene(root);
	   primaryStage.setScene(scene);
	   primaryStage.setTitle("ConsistComposite");
	   primaryStage.show();
	  } catch (Exception e) {
	   e.printStackTrace();
	  }
	 }

	 public static void main(String[] args) {
	  launch(args);
	 }
	
//	public static void main(String[] args) {
//		// TODO Auto-generated method stub
//
//		Team team1=new Team();
//		Team team11=new Team();
//		Team team12=new Team();
//		Team temp=new Team();
//		Person person11=new Person();
//		Person person12=new Person();
//		Person person121=new Person();
//		Person person122=new Person();
//		Person person123=new Person();
//		Person person124=new Person();
//		team1.setName("team1");
//		team11.setName("team11");
//		team12.setName("team12");
//		person11.setName("person11");
//		person12.setName("person12");
//		person121.setName("person121");
//		person122.setName("person122");
//		person123.setName("person123");
//		person124.setName("person124");
//		add(team1, person11);
//		add(team1, person12);
//		add(team1, team11);
//		add(team11,person121);
//		add(team11,person122);
//		add(team11,person123);
//		add(team1,team12);
//		team1.searchChild(team1,0);
//		System.out.println("--------------");
//		if(search(team1,"person123") instanceof Team) {
//			team12.addChild(person124);
//		}else {
//			Team team=new Team();
//			Person person=new Person();
//			team.setName("team");
//			temp=(Team) search(team1,"person123").getTeam();
//			person=(Person) search(team1,"person123");
//			temp.removeChild(search(team1,"person123"));
//			temp.addChild(team);
//			team.addChild(person);
//			team.addChild(person124);
//		}
//		team1.searchChild(team1,0);
//        Component result=search(team1,"person12");
//        if(result!=null)
//        System.out.println(result.getName());
//        Set<Component> children=new HashSet();
//        children=team1.getChildren();
//        for(Component temp:children) {
//        	System.out.println(temp.getName());
//        }
//        //删除team1的team12
//        team12.getTeam().removeChild(team12);
//        children=team1.getChildren();
//        for(Component temp:children) {
//        	System.out.println(temp.getName());
//        }
//	}
//	
//	
//	public static void add(Component father,Component son) {
//		((Team) father).addChild(son);
//		son.setTeam(father);
//	}
//	
//	
//
//	public static Component search(Component team,String name) {
//		if(team instanceof Team) {
//			if(team.getName()==name) {
//				return team;
//			}	
//			Set<Component> children=new HashSet();
//	        children=((Team)team).getChildren();
//	        Component result=null;
//            for(Component temp:children) {
//            	result=search(temp,name);
//            	if(result!=null) {
//            		return result;
//            	};
//	        }
//		}
//		else if(team instanceof Person){
//			if(team.getName().equals(name)) {
//				return team;
//			}
//		}
//		return null;
//	}
}
